#-*-encoding=utf-8-*-
steps = [
    FlowStep(
        name=u'init',
        title=u'报告',
        fields=[u'title', u'description', u'handler', u'reason', u'version', u'module', u'validator', u'subscribers', u'attach'],
        responsibles=u'[request.principal.id]',
    actions=[
        FlowStepAction(
            name=u'提交',
            title=u'提交',
            nextsteps=[u'deliever'],
            trigger=ur"""ITagsManager(sheet).addTag('提交', True)""",
            condition=u'request.principal.id not in flowsettings["deliverer"]'
),

        FlowStepAction(
            name=u'分派',
            title=u'分派',
            nextsteps=[u'handle'],
            condition=u'request.principal.id in flowsettings["deliverer"]'
)
])
,

    FlowStep(
        name=u'deliever',
        title=u'分派',
        fields=[u'title', u'description', u'solution', u'reason', u'handler', u'version', u'module', u'validator', u'subscribers'],
        trigger=ur"""msg_notifier.send(title='new bug: ' + sheet["title"],
              body=sheet['description'],
              to_ids=task.responsibles,
              bound_obj=sheet)
""",
        responsibles=u'flowsettings["deliverer"]',
    actions=[
        FlowStepAction(
            name=u'分派',
            title=u'分派',
            nextsteps=[u'handle'],
            finish_condition=u''
),

        FlowStepAction(
            name=u'不是故障',
            title=u'不是故障',
            nextsteps=[u'confirm'],
            trigger=ur"""ITagsManager(sheet).addTag('不是故障', True)"""
),

        FlowStepAction(
            name=u'完成',
            title=u'完成',
            nextsteps=[u'confirm'],
            trigger=ur"""ITagsManager(sheet).addTag('完成', True)""",
            finish_condition=u''
)
])
,

    FlowStep(
        name=u'handle',
        title=u'处理',
        fields=[u'solution', u'handler', u'reason', u'version', u'module', u'subscribers', u'attach', u'title', u'description'],
        trigger=ur"""ITagsManager(sheet).addTag('处理', True)

msg_notifier.send(title='new bug: ' + sheet['title'],
              body=sheet['description'],
              to_ids=task.responsibles + sheet['subscribers'],
              bound_obj=sheet)
""",
        responsibles=u'sheet["handler"]',
    actions=[
        FlowStepAction(
            name=u'不是故障',
            title=u'不是故障',
            nextsteps=[u'confirm'],
            trigger=ur"""ITagsManager(sheet).addTag('处理', True)"""
),

        FlowStepAction(
            name=u'完成',
            title=u'完成',
            nextsteps=[u'confirm'],
            trigger=ur"""ITagsManager(sheet).addTag('完成', True)"""
),

        FlowStepAction(
            name=u'不该我处理',
            title=u'不该我处理',
            nextsteps=[u'deliever'],
            trigger=ur"""ITagsManager(sheet).addTag('提交', True)"""
)
])
,

    FlowStep(
        name=u'confirm',
        title=u'验收',
        fields=[u'title', u'description', u'score', u'check_result', u'attach'],
        trigger=ur"""msg_notifier.send(title='bug confirm: ' + sheet["title"],
              body=sheet['description'],
              to_ids=task.responsibles,
              bound_obj=sheet)
""",
        responsibles=u'sheet["validator"]',
    actions=[
        FlowStepAction(
            name=u'确认故障已经解决',
            title=u'确认故障已经解决',
            nextsteps=[],
            trigger=ur"""ITagsManager(sheet).addTag('验收', True)"""
),

        FlowStepAction(
            name=u'这不是一个故障',
            title=u'这不是一个故障',
            nextsteps=[],
            trigger=ur"""ITagsManager(sheet).addTag('不是故障', True)"""
),

        FlowStepAction(
            name=u'再次提交',
            title=u'打回再次提交',
            nextsteps=[u'handle'],
            finish_condition=u''
)
])
]
